package www.sofn.com.sys.resource;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import www.sofn.com.domain.vo.SelectTreeVO;
import www.sofn.com.sys.resource.domain.Pojo.SysResourcePO;

import java.util.List;
import java.util.stream.Collectors;

@Service
public class SysResourceService {
    @Autowired
    private SysResourceMapper sysResourceMapper;
    public List<SelectTreeVO> findSysResources() {
        final List<SysResourcePO> sysResourcePOS = sysResourceMapper.selectList(null);
        List<SelectTreeVO> selectTrees = sysResourcePOS.stream().map(v -> {
            SelectTreeVO selectTreeVO = new SelectTreeVO();
            selectTreeVO.setParentId(v.getParentsCode()).setName(v.getName()).setId(v.getCode());
            return selectTreeVO;
        }).collect(Collectors.toList());
        return selectTrees;
    }

}
